home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d11 / bwvid.arc / BWVID.ASM next >
Assembly Source File  |  1988-01-09  |  11KB  |  255 lines

  1. page ,132
  2. ;**************************************************************************
  3. ; The following is an Interrupt/Stay resident program that intercepts all
  4. ; BIOS video calls involving color and maps them to black and white calls.
  5. ; It will eliminate many of the fuzzy screens that arise from having
  6. ; a BW monitor hooked up to a color graphics board.
  7. ; THIS PROGRAM IS ONLY USEFUL IF YOU HAVE A BLACK AND WHITE HIGH RESOLUTION
  8. ; MONITOR CONNECTED TO YOUR GRAPHICS CARD.
  9. ;
  10. ; PROBLEMS THAT THIS ROUTINE SOLVES:
  11. ;    This program, when installed will remove all the fuzzy displays that
  12. ;    result when color display instructions are sent to BW monitor through
  13. ;    the BIOS system.  The VAST MAJORITY of available code does go through
  14. ;    BIOS so this will catch most of those problems.  This program works
  15. ;    by intercepting the following video calls and changing them as described.
  16.  
  17. ;    SET MODE FUNCTION (INT 10H, AH=0)
  18. ;    If BIOS call is to set mode to 40x25 color then force mode to 40x25 BW
  19. ;    If BIOS call is to set mode to 80x25 color then force mode to 80x25 BW
  20. ;    If BIOS call is to set mode to 320x200 color then force mode to 320x200 BW
  21.  
  22. ;    WRITE CHARACTER AND ATTRIBUTE (INT 10H, AH=9)
  23. ;    Intercepts BIOS calls to write attributes and characters and changes
  24. ;    the attributes.  In the following, "Normal Video" is defined as White
  25. ;    (or Intense white) on black.  "Reverse Video" is defined as black on white
  26. ;    (or Intense white).  Attributes are modified as follows:
  27. ;         IF foreground and background are the same THEN
  28. ;            IF they are black or white THEN leave them alone
  29. ;            ELSE they are another color so force to white
  30. ;         ELSE
  31. ;            IF foreground is black OR background is white THEN force "Reverse Video"
  32. ;            ELSE force "Normal Video"
  33. ;
  34. ;    SCROLL PAGE UP (INT 10H, AH=6) or SCROLL PAGE DOWN  (INT 10H, AH=7)
  35. ;    Intercepts BIOS calls to scroll up or down and changes the attribute
  36. ;       associated with the call as described immediately above for write character.
  37.  
  38. ;    SET COLOR PALATTE  (INT 10H, AH=11)
  39. ;    Intercepts BIOS graphic calls to set the palette and changes them such that:
  40. ;       *  Background is always black
  41. ;       *  Foreground pallate always includes white (Color Id = 1)
  42.  
  43. ;    WRITE DOT (INT 10H, AH=12) and WRITE TELETYPE (INT 10H, AH=14)
  44. ;    The "Write Dot" and "Write Teletype" intercept functions both map fore-
  45. ;       ground to white, regardless of the intended color.
  46. ;
  47. ; PROBLEMS THAT THIS ROUTINE CREATES:
  48. ;    When information is transmitted to the view SOLELY through color
  49. ;    information, then that information is lost in this transformation.
  50. ;    (naturally!).  So if, for example, a game has a color bar that switches
  51. ;    from green to red to signify danger, that information will be lost.
  52. ;    This is because generally all foreground colors are forced to white and
  53. ;    all background colors are forced to black.  This is not so much a
  54. ;    problem created by this program as it is a problem with Black and White
  55. ;    monitors not conveying as much information as Color Monitors.
  56. ;
  57. ; PROBLEMS THAT THIS ROUTINE DOES NOTHING ABOUT:
  58. ;    Any video calls that go straight to the hardware instead of going
  59. ;    through BIOS.  It is unfortunately the case that some VERY sophisticated
  60. ;    programs that really have snazzy graphics do go to the hardware directly
  61. ;    because of the speed benefits.
  62. ;
  63. ; After installing this program, all of the IBM Diagnostic tests look
  64. ; reasonable.
  65. ;
  66. ; When loaded this program uses 309 Decimal bytes of memory including the
  67. ; Program Segment Prefix (It relocates itself down into the unused portion
  68. ;     of the Program Segment Prefix to save memory).
  69. ;
  70. ; BWVID - Version 1.2, (C) Copyright 1985 by Scott W. Killen, All Rights Reserved
  71. ;         This program may not be used for commercial purposes without the
  72. ;            express written consent of Scott W. Killen.
  73. ; Version 1.0 - 5/02/85
  74. ; Version 1.1 - 8/20/85
  75. ; Version 1.2 - 8/29/85
  76. ; By:
  77. ;    Scott W. Killen
  78. ;    P.O Box 27012
  79. ;    Austin Texas  78755
  80. ;    CIS ID: 76703,734
  81. ;    512/836-1942
  82. ;
  83. ; This program is GiveAware!  The only payment I ask is your comments and
  84. ; bug reports.
  85. ;**************************************************************************
  86.  
  87. white      MACRO   reg            ; Force register to have white color code
  88.            LOCAL   continue       ;    if not backgound.
  89.            mov     ah,0f8h        ; Get ready for masking high bits
  90.            and     ah,reg         ; Save High order bits
  91.            and     reg,0fh        ; test for foreground or background
  92.            jz      continue       ; If background then we are finished
  93.            or      reg,07h        ; Force to white (or intense white) foreground
  94. continue:  or      reg,ah         ; Recombine the two parts
  95.            ENDM
  96.  
  97. CSEG    SEGMENT
  98.         ASSUME CS:CSEG
  99.         ORG 100H
  100.  
  101. BWVID  PROC NEAR
  102.           JMP     initialize
  103. CodeStart   equ 5ch
  104. RelocWidth  equ $-CodeStart
  105. JumpVector  equ $-RelocWidth
  106. JumpTable   dw  Test0   -RelocWidth
  107.             dw  JumpBios-RelocWidth
  108.             dw  JumpBios-RelocWidth
  109.             dw  JumpBios-RelocWidth
  110.             dw  JumpBios-RelocWidth
  111.             dw  JumpBios-RelocWidth
  112.             dw  Test6   -RelocWidth
  113.             dw  Test7   -RelocWidth
  114.             dw  JumpBios-RelocWidth
  115.             dw  Test9   -RelocWidth
  116.             dw  JumpBios-RelocWidth
  117.             dw  Test11  -RelocWidth
  118.             dw  Test12  -RelocWidth
  119.             dw  JumpBios-RelocWidth
  120.             dw  Test14  -RelocWidth
  121.             dw  JumpBios-RelocWidth
  122. EndJumpVector equ $-RelocWidth
  123. BiosVector    equ $-RelocWidth
  124. BiosAddress dd ?
  125.  
  126. EntryPoint  equ  $-RelocWidth
  127.             push    di
  128.             xchg    ah, al
  129.             mov     di, ax
  130.             xchg    ah, al
  131.             and     di, 0ffh               ; Put AH in DL
  132.             shl     di, 1                  ; Multiply times 2
  133.             add     di, JumpVector         ; Add in Base address
  134.             cmp     di, EndJumpVector      ; Is our vector out of range?
  135.             jge     JumpBios
  136.             jmp     Word Ptr cs:[di]       ; Jump to function
  137.  
  138. Test0:      cmp     al, 03H        ; Check if Alpha Mode
  139.             jg      Test0a         ; Jump if not Alpha mode
  140.             and     al, 02H        ; Force black and white display
  141.             jmp     Short JumpBios
  142. Test0a:     cmp     al, 05H        ; Check for Medium Res Graphics
  143.             jg      JumpBios       ; Jump if not Medium Res Graphics
  144.             mov     al, 05H        ; Force black and white graphics
  145.  
  146. Test6:
  147. Test7:
  148.             push    ax             ; Save the function value
  149.             xchg    bh, bl         ; Put attribute in BL
  150.             call    AdjustAttr     ; Adjust the attribute in BL
  151.             xchg    bh, bl         ; Return attribute to BH
  152.             pop     ax             ; Restore function (destroyed by AdjustAttr)
  153.  
  154. JumpBios:   pop     di
  155.             jmp     DWord Ptr cs:[BiosVector]
  156.  
  157. Test9:
  158.             call    AdjustAttr
  159.             mov     ah, 09h        ; Restore AH and return to BIOS
  160.             jmp     Short JumpBios
  161.  
  162. Test11:     and     bl, 0f0h       ; Zero out low bits (black background)
  163.             or      bh, bh         ; Is it a set background?
  164.             jz      Test11a        ; if so, we are finished
  165.             mov     bl, 01h        ; Set palette one
  166. Test11a:    jmp     Short JumpBios
  167.  
  168. Test12:     white   al             ; Force the color (if any) to white
  169.             mov     ah,0CH         ; Now restore function code
  170.             jmp     Short JumpBios
  171.  
  172. Test14:     white   bl             ; Force foreground (if any) to white
  173.             mov     ah,0EH         ; Restore function code
  174.             jmp     Short JumpBios
  175. BWVID  endp
  176.  
  177. AdjustAttr  Proc  Near             ; Adjust attribute in BL
  178.                                    ; AH destroyed, and BL modified
  179.             push    bx
  180.             mov     ah,bl          ; Use the AH register for a minute
  181.             and     ah, 07h        ; Isolate the foreground color
  182.             sar     bl, 1          ; Shift the background into right portion of word
  183.             sar     bl, 1
  184.             sar     bl, 1
  185.             sar     bl, 1
  186.             and     bl, 07h        ; Isolate the background color
  187.             cmp     ah, bl         ; Compare foreground and background
  188.             je      AA2            ; Jump if they are the same
  189.             or      ah, ah         ; Is foreground black?
  190.             jz      AA1            ; If so then force reverse video
  191.             cmp     bl, 07h        ; Is background white?
  192.             jz      AA1
  193.             pop     bx             ; Ok, so it is normal video
  194.             or      bl, 07h        ; force foreground on,
  195.             and     bl, 8fh        ; and background off!
  196.             ret
  197. AA1:
  198.             pop     bx
  199.             or      bl, 70h        ; force background on,
  200.             and     bl, 0f8h       ; and foreground off!
  201.             ret
  202. AA2:
  203.             or      bl, bl         ; Test to see if they are off
  204.             pop     bx
  205.             jz      AA3
  206.             or      bl, 77h        ; Force foreground and background on!
  207. AA3:        ret
  208. AdjustAttr  endp
  209.  
  210. CODEWIDTH   equ  $-JumpTable
  211. INIT   PROC  NEAR
  212. cpyrite   db  'BWVID - Version 1.2, (C) Copyright 1985 by Scott W. Killen, All Rights Reserved$'
  213. initialize:
  214.         PUSH    DS                          ; Save DS for later use
  215.         XOR     AX,AX                       ; Clear AX
  216.         MOV     DS,AX                       ; Prepare to save original interrupt
  217. ;
  218.         MOV     AX, 40H
  219.         MOV     SI, AX                      ; Source for INT 10h as provided for in the interrupt table
  220.         MOV     DI, Offset BiosAddress      ; Destination in the code segment for moving this pointer
  221.         MOVSW                               ; Move the two word address
  222.         MOVSW
  223. ;
  224.         MOV     AX, EntryPoint         ; Fill AX with starting point
  225.         MOV     [SI-04H],AX            ; Move offset in line
  226.         MOV     [SI-02H],CS            ; Move segment value in line
  227. ;
  228.         POP     DS                     ; Restore the data segment
  229. ;
  230.                                        ; These lines relocate the interrupt
  231.         MOV     CX, CodeWidth          ;   handler down into the unused
  232.         MOV     DI, CodeStart          ;   portion of the Program Segment
  233.         MOV     SI, Offset JumpTable   ;   Prefix (to save memory)!
  234.  REP    MOVSB                          ;
  235. ;
  236.         mov     ah, 0fh                ; Interrupt is now installed
  237.         int     10h                    ; Return the current mode
  238.         xor     ah, ah                 ; Set mode function
  239.         int     10h                    ; Reset the current mode (taking BW defaults)
  240. ;
  241.         mov     dx, offset cpyrite     ; Display copyright
  242.         mov     ah, 9
  243.         int     21h
  244. ;
  245.         mov     ah, 2                  ; Set the cursor position
  246.         mov     dx, 300h
  247.         xor     bx, bx
  248.         int     10h
  249. ;
  250.         MOV     DX, (offset initialize - offset JumpTable)+CodeStart ; Top of code address
  251.         INT     27H                    ; Terminate but stay resident
  252. INIT    ENDP
  253. CSEG    ENDS
  254.         END  BWVID
  255.